//define(function(require,exports,module){
angular.module('mobileApp')
    .controller('MainCtrl',["$scope","$http","$window", function ($scope,$http,$window) {

        $scope.next = '<a href="/res/static/index.html#/auth" target="_self"><i class="icon-font" title="我的">&#xe61e;</i></a>';
        var hasAd = false,
            screen = ($window.innerWidth);
        $scope.screenWidth = screen+"px";
        $scope.index=0;
        $scope.adList =[
            {"imagePath":"http://placehold.it/640x275/7ecdc5/fff"}
        ];
        //请求广告列
        //$http.get(hpfbase.url+"/common/ad-dish-list.jhtm")
        //    .success(function(ret){
        //        if(ret.statusCode){
        //            $scope.adList = ret.data;
        //            $scope.totalWidth = screen*$scope.adList.length+'px'
        //            scroll();
        //        }
        //    });
        //广告滑动
        var scroll = function(){
            var total;
            if($scope.adList){
                hasAd = true;
                total=$scope.adList.length-1;
            }
            var index = 0;
            $scope.sildeLeft = function(){
                if(index<total)
                    index++;
                else
                    index=0;
                $scope.marginLeft = -index*screen+"px";
                $scope.index = index;
            };
            $scope.sildeRight = function(){
                if(index>0)
                    index--;
                else
                    index=total;
                $scope.marginLeft = -index*screen+"px";
                $scope.index = index;
            }
        }
        scroll();

    }]);
//})